<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Infotech Ltd.
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: vshoor $ ($Date: 2005/09/18 17:40:22 $)
// $RCSfile: upgrade.php,v $ : $Revision: 1.4 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================


if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

// Core Module
$_SWIFT["query"]["alter"]["users"][] = "ALTER TABLE `". TABLE_PREFIX ."users` ADD (slaexpiry INT UNSIGNED NOT NULL DEFAULT '0', ismanager INT UNSIGNED NOT NULL DEFAULT '0');";
$_SWIFT["query"]["alter"]["usergroups"][] = "ALTER TABLE `". TABLE_PREFIX ."usergroups` ADD (slaexpiry INT UNSIGNED NOT NULL DEFAULT '0');";

// Is Tickets Module Registered?
if (in_array(MODULE_TICKETS, $registeredmodules))
{
	// Modify the Index
	$_SWIFT["query"]["alter"]["tickets"][] = "ALTER TABLE `". TABLE_PREFIX ."tickets` DROP INDEX `tickets2`;";
	$_SWIFT["query"]["alter"]["tickets"][] = "ALTER TABLE `". TABLE_PREFIX ."tickets` ADD INDEX tickets2 (`slaplanid`, `duetime`, `ticketstatusid`);";

	$_SWIFT["query"]["create"]["ticketlocks"] = "CREATE TABLE ". TABLE_PREFIX ."ticketlocks (
																	ticketid INT UNSIGNED NOT NULL DEFAULT '0',
																	lockstaffid INT UNSIGNED NOT NULL DEFAULT '0',
																	lockdateline INT UNSIGNED NOT NULL DEFAULT '0',
																	UNIQUE KEY ticketlocks1 (ticketid)
																);";

	$_SWIFT["query"]["alter"]["ticketlocks"][] = "ALTER TABLE `". TABLE_PREFIX ."ticketlocks` TYPE = HEAP;";
}

// Is Live Support Module Registered?
if (in_array(MODULE_LIVESUPPORT, $registeredmodules))
{
	// Modify the Index
	$_SWIFT["query"]["alter"]["chatobjects"][] = "ALTER TABLE `". TABLE_PREFIX ."chatobjects` DROP INDEX `chatobjects1`;";
	$_SWIFT["query"]["alter"]["chatobjects"][] = "ALTER TABLE `". TABLE_PREFIX ."chatobjects` ADD INDEX chatobjects1 (`chatstatus`, `staffid`, `lastpostactivity`);";
	
}

// Is Knowledgebase Module Registered?
if (in_array(MODULE_KNOWLEDGEBASE, $registeredmodules))
{
	$_SWIFT["query"]["alter"]["kbarticledata"][] = "ALTER TABLE `". TABLE_PREFIX ."kbarticledata` ADD FULLTEXT (`contents`);";
}

upgrade_updateVersion("3.00.12");
?>